package com.dzzw.Servlet.ForumServlet;

import com.dzzw.Dao.ForumDao;
import com.dzzw.Model.Forum;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/View/ForumModifyServlet")
public class ForumModifyServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private final ForumDao forumDao= new ForumDao();
    public ForumModifyServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        int forum_id = Integer.parseInt(request.getParameter("forum_id"));
        String forum_title = request.getParameter("forum_title");
        String forum_content = request.getParameter("forum_content");
        Forum forum = new Forum();
        forum.setForum_id(forum_id);
        forum.setForum_title(forum_title);
        forum.setForum_content(forum_content);
        forumDao.ForumModify(forum);
        response.sendRedirect("/View/SelectAllForumById.jsp");
    }
}
